from CaseAW.GridBase import winAppBase
from CaseAW.ViewBase import view_base
from CaseAW.mesh import mesh_base
from CaseAW.modelTree import tree_base
from CaseAW.openfile import file_base


class winApp(file_base,mesh_base,tree_base,view_base,geom_base,block_base,work_flow,winAppBase):
    def __init__(self,caseinfo=None,desired_caps=None,host="localhost",port="4723"):
        super(winApp,self).__init__(desired_caps=desired_caps,host=host,port=port)
        self.attach_caseinfo(caseinfo)
        self.caseinfo=caseinfo

    def assert_caseinfo_exist(self):
        if "id" in self.caseinfo.keys():
            return True
        else:
            return False

    def get_case_info(self,num:int):
        if self.assert_caseinfo_exist():
            item=self.caseinfo["step"][num-1]
            print_string="步骤：{} \n 预期：{}".format(item["desc"],item["expect"])
            return print_string
        return "******用例信息，获取失败******"

    def get_case_pre_step(self):
        if self.assert_caseinfo_exist():
            print_string="前置：{}".format(self.caseinfo["precondition"])
            return print_string
        return "******用例信息，获取失败******"

    def set_file_dir(self,path):
        self.work_file_dir=path
